package;
import haxe.macro.Context;
import haxe.macro.Expr;
import scuts.macro.Parse;
import scuts.macro.Print;


/**
 * ...
 * @author 
 */

class MyMacro 
{

	@:macro public static function testParsing(body:Expr) 
	{
		
    
	
		var expr = Parse.parse('function () $body', { body:body } );
		
    trace("\n" + Print.exprStr(expr));
		
    
    var myArray = Parse.parse('["a","b"]');
    
    trace("\n" + Print.exprStr(myArray));
		
    var parsed1 = Parse.parse('function (a:$myType) return $myBody', { myType:'Array<String>', myBody: myArray } );
    
		trace("\n" + Print.exprStr(parsed1));
		
    
    
    var parsed2 = Parse.parse('function (a:$myType):$myType return $myBody', { myType:Context.typeof(myArray), myBody: myArray } );
    
    
		trace("\n" + Print.exprStr(parsed2));
		
    var templateType = Context.getType("haxe.Template");
    var myExpr = Parse.parse("new haxe.Template()");
    
    var parsed3 = Parse.parse('{var a:$myType = $myExpr;}', { myType:templateType, myExpr: myExpr} );
    
    
		trace("\n" + Print.exprStr(parsed3));
    
    
   
    var parsed4 = Parse.parse('{var a:$myType<$myType2> = ["a"];}', { myType:'Array', myType2:'String'} );
    
    
		trace("\n" + Print.exprStr(parsed4));
    
    var parsed5 = Parse.parse('{var a:$0<$1> = ["a"];}', ['Array', 'String'] );
    
    
		trace("\n" + Print.exprStr(parsed5));
    
    
		return body;
	}
  

  
  
	
}